//
//  BLCaiJiCenterViewController.m
//  blanket
//
//  Created by Mac on 2018/11/1.
//  Copyright © 2018 stoneobs@icloud.com. All rights reserved.
//

#import "BLCaiJiCenterViewController.h"
#import "BLHotelCustomViewController.h"

@interface BLCaiJiCenterViewController ()

@end

@implementation BLCaiJiCenterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"采集商城";
    [self configSubView];
    // Do any additional setup after loading the view.
}

#pragma mark --subView
- (void)configSubView{
    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 100)];
//    header.backgroundColor = [UIColor whiteColor];
    
        __weak typeof(self) weakSelf =  self;
    STButton * sharesButton = [[STButton alloc] initWithFrame:CGRectMake(30, 60, UIScreenWidth - 60, 60)
                                                        title:@"酒店布草定制"
                                                   titleColor:[UIColor whiteColor]
                                                    titleFont:16
                                                 cornerRadius:5
                                              backgroundColor:BL_BlueBackGroundColor
                                              backgroundImage:nil
                                                        image:nil];
    sharesButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [header addSubview:sharesButton];
    [sharesButton setClicAction:^(UIButton *sender) {
         [weakSelf onSelectedWithSender:sender];
    }];
    
    
    STButton * reduceButton = [[STButton alloc] initWithFrame:CGRectMake(30, sharesButton.bottom + 40, UIScreenWidth - 60, 60)
                                                        title:@"芯类定制(采购)"
                                                   titleColor:BL_BlueBackGroundColor
                                                    titleFont:16
                                                 cornerRadius:5
                                              backgroundColor:[UIColor whiteColor]
                                              backgroundImage:nil
                                                        image:nil];
    reduceButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [header addSubview:reduceButton];
    [reduceButton st_setBorderWith:1 borderColor:BL_BlueBackGroundColor cornerRadius:5];
    [reduceButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelectedWithSender:sender];
    }];
    reduceButton.tag = 10001;
    STButton * jinneiButton = [[STButton alloc] initWithFrame:CGRectMake(30, reduceButton.bottom + 40, UIScreenWidth - 60, 60)
                                                        title:@"巾类定制"
                                                   titleColor:BL_BlueBackGroundColor
                                                    titleFont:16
                                                 cornerRadius:5
                                              backgroundColor:[UIColor whiteColor]
                                              backgroundImage:nil
                                                        image:nil];
    jinneiButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [header addSubview:jinneiButton];
    [jinneiButton st_setBorderWith:1 borderColor:BL_BlueBackGroundColor cornerRadius:5];
    [jinneiButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelectedWithSender:sender];
    }];
    jinneiButton.tag = 10002;
    
    STButton * dihaoButton = [[STButton alloc] initWithFrame:CGRectMake(30, jinneiButton.bottom + 40, UIScreenWidth - 60, 60)
                                                        title:@"低耗定制(采购)"
                                                   titleColor:BL_BlueBackGroundColor
                                                    titleFont:16
                                                 cornerRadius:5
                                              backgroundColor:[UIColor whiteColor]
                                              backgroundImage:nil
                                                        image:nil];
    dihaoButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [header addSubview:dihaoButton];
    [dihaoButton st_setBorderWith:1 borderColor:BL_BlueBackGroundColor cornerRadius:5];
    [dihaoButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelectedWithSender:sender];
    }];
    dihaoButton.tag = 10003;
    
    
    STButton * buyButton = [[STButton alloc] initWithFrame:CGRectMake(30, dihaoButton.bottom + 40, UIScreenWidth - 60, 60)
                                                     title:@"备注:若商城中没有符合酒店个性需求化的产品,请联系客服!打开QQ>"
                                                titleColor:FirstTextColor
                                                 titleFont:14
                                              cornerRadius:0
                                           backgroundColor:nil
                                           backgroundImage:nil
                                                     image:nil];
  
    [header addSubview:buyButton];
    buyButton.titleLabel.numberOfLines = 0;
    [buyButton setAttributedTitle:[buyButton.currentTitle st_convertAttributeStringWithKeyWord:@"打开QQ>" attributes:@{NSForegroundColorAttributeName:FlatBlue}] forState:UIControlStateNormal];
    header.height = buyButton.bottom ;
    self.tableView.tableHeaderView = header;
    [buyButton setClicAction:^(UIButton *sender) {
        NSString *qqNumber = @"2734173668";
        NSString *openQQUrl = [NSString stringWithFormat:@"mqq://im/chat?chat_type=wpa&uin=%@&version=1&src_type=web",qqNumber];
        NSURL *url = [NSURL URLWithString:openQQUrl];
        [[UIApplication sharedApplication] openURL:url];
    }];

}
#pragma mark --Action Method
//酒店布草定制
- (void)onSelectedHotelButton{
    
    [self.navigationController pushViewController:[BLHotelCustomViewController new] animated:YES];
}
//私人布草定制
- (void)onSelectedWithSender:(UIButton*)sender{
    BLHotelCustomViewController * vc = [BLHotelCustomViewController new];
    vc.subtype = @(sender.tag-10000).description;
    vc.title = sender.currentTitle;
    [self.navigationController pushViewController:vc animated:YES];
}

@end
